<?php 
## include required files
/*******************************/
require_once '../model/sitesettings.php';
## Paginaton class
require_once ("../includes/classes/pagination_class.php");
/*******************************/

## Create Objects
/*******************************/
$settingObj = new Model_Sitesettings();
/*******************************/

/*******************************/
##Fetch all config settings from database

##  --------- Pagination part first start --------------##
	if( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] != "" ) {
		$pageNum = $_GET[ 'page' ];
	} else {
		$pageNum = 1;
	} 
	$rowsPerPage = ROW_PER_PAGE;
	$pageName = "home.php?q=sitesettings"; 
	## Count all the records
	$settingsArray = $settingObj->getSiteSetting();
	$total_rows = count($settingsArray);
	$offset	= ($pageNum - 1) * $rowsPerPage;
	$smarty->assign('page', $pageNum);
##  --------- Pagination part first end --------------##


##  --------- Pagination part second start --------------##
	$newid = $pageNum * $rowsPerPage - $rowsPerPage + 1;
	$smarty->assign('newid', $newid);
	$configArray = $settingObj->getSiteSetting($rowsPerPage,$offset);
	//echo "<pre>"; print_r($cmsArray);exit;
	$smarty->assign('settingsArray', $settingsArray);
	if($total_rows > ROW_PER_PAGE) {
		$pg = new pagination();					// CREATING OBJECT OF THE PAGINATION CLASS
		$pgnation = $pg->pagination_admin( $total_rows , $rowsPerPage , $pageNum , $pageName , $other_id, $class);	
		$smarty-> assign("pagination",$pgnation);
	}
##  --------- Pagination part second end --------------##	

## Assign session message to smarty variable and unset session variable
if($_SESSION['msg'] != '') {
	$smarty->assign('msg', $_SESSION['msg']);	
	unset($_SESSION['msg']);
}

## Set active class variable for left menu (main menu and sub menu)
$smarty->assign('activeclass', 'sitesettings');
$smarty->assign('mainmenu', '5');

## Unset all the objects created which are on this page
unset($settingObj);

$smarty->display(TEMPLATEDIR_ADMIN. 'settings/sitesettings.tpl');
unset($smarty);
?>